package com.cmnit.analysis.dao

import com.cmnit.analysis.common.TDao
import org.apache.log4j.Logger
import org.apache.spark.sql.DataFrame

class GantryDao extends TDao {
  private val logger: Logger = Logger.getLogger(this.getClass)

  /**
   * 加工结果数据
   */
  def gantryData(sqlTime: String, acctTime: String): DataFrame = {
      sparkSQL(
        "select " +
          "nvl(TradeId,' ') TradeId, " +
          "nvl(PassId,' ') PassId, " +
          "nvl(GantryId,' ') GantryId, " +
          "nvl(split(vehicleplate,'_')[1],' ') vehiclecolor, " +
          "getVehiclePlateMD5(vehicleplate) vehicleplate, " +
          "nvl(VehicleType,' ') VehicleType, " +
          "nvl(transtime,' ') transtime, " +
          "nvl(Fee,' ') Fee, " +
          "nvl(PayFee,' ') PayFee, " +
          "nvl(DiscountFee,' ') DiscountFee, " +
          "nvl(MediaType,' ') MediaType, " +
          "nvl(VehicleClass,' ') VehicleClass, " +
          "nvl(EnTollStationHex,' ') EnTollStationHex, " +
          "nvl(EnTime,' ') EnTime, " +
          "nvl(FeeCalcResult,' ') FeeCalcResult, " +
          "nvl(OBUdiscountFeeSumBefore,' ') OBUdiscountFeeSumBefore, " +
          "nvl(OBUdiscountFeeSumAfter,' ') OBUdiscountFeeSumAfter, " +
          "'" + acctTime + "' as statishour, " +
          "'" + acctTime.substring(0, 8) + "' as statisday " +
          "from " +
          "ods.ods_etc_gantryetcbill " +
          "where "
          + sqlTime +
          "and ((mediatype='1' and obutraderesult='0' and obuprovfeesumafter<=100000000) or (mediatype='2' and traderesult='0' and feeSumLocalAfter<=100000000)) ")
  }
}
